package com.stars.home.vmodel

import android.app.Activity
import android.app.Application
import android.text.TextUtils
import androidx.databinding.Bindable
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.stars.home.BR
import com.stars.home.activity.ForgetPasswordActivity
import com.stars.home.model.User
import com.stars.home.utils.net.NetEngine
import com.trailer.base.base.BRepository
import com.trailer.base.base.BViewModel
import com.trailer.base.utils.UiSwitch

import kotlinx.coroutines.launch
import java.util.HashMap

class ChangePasswordVModel(application: Application) : BViewModel<BRepository>(application) {

    var user: MutableLiveData<User> = MutableLiveData(User.get())



    @Bindable
    open var passWord: String? = null
        set(value) {
            field = value
            notifyPropertyChanged(BR.passWord)
        }


    @Bindable
    open var oldpassWord: String? = null
        set(value) {
            field = value
            notifyPropertyChanged(BR.oldpassWord)
        }



    fun toClose(){
        ( repository().context as Activity).finish()

    }


    fun toForgetPassword(){
        UiSwitch.single(repository().context, ForgetPasswordActivity::class.java)

    }


    fun toSure(){
        //确认
        var oldpwd = ""

        if (TextUtils.isEmpty(passWord)) {
            toast("请输入新密码")
            return
        }

        var map = HashMap<String, String>()
        map["origina_password"] = oldpwd
        map["password"] = passWord.toString()



    }


}



